/**
 * @company : 版权所属 四川北星惯牌科技有限公司
 * @contact : 刘经理 19326416371
 **/
import {
	defineStore
} from 'pinia';
export const assistantStore = defineStore('assistantStore', {
	state: () => ({
		assistantInfo: {
			avatar: '',
			nickname: '',
			level: 0,
			levelName: '',
			introduce: '',
		}, //助教信息
		photoWall: [],
		assistantOrder: null,
		accountInfo: null,
		assistantItemInfo: null


	}),
	getters: {},
	actions: {
		async getAssistantinfo() {
			const res = await $Api.assistant.getAssistantInfo();
			if (res.code == 1) {
				if (res.data.level && level_info?.value) {
					let info = level_info.value.find(item => item.vl_id == res.data.level)
					// console.log('info', info);
					if (info && info.vip_name) {
						res.data.levelName = info.vip_name + '助教'
					} else {
						res.data.levelName = '普通助教'
					}
				} else {
					res.data.levelName = '普通助教'
				}
				if (!res.data.introduce) {
					res.data.introduce = ''
				}
				this.assistantInfo = res.data;
			} else {
				uni.$u.toast(res.msg);
			}
		},
		async getPhotoWall() {},
		setAssistantInfo(info) {
			this.assistantInfo = info
		},
		setAssistantItem(info) {
			this.assistantItemInfo = info;
		},
		setAssistantOrder(info) {
			this.assistantOrder = info;
		},
		setAccount(info) {
			this.accountInfo = info;
		},
	},
	persist: {
		storage: {
			getItem(key) {
				return uni.getStorageSync(key)
			},
			setItem(key, value) {
				return uni.setStorageSync(key, value)
			},
		},
	},
})